package org.liulinlin.sejw.db;

import java.sql.*;

public class ShipInfo { //extends DataAccessServiceImpl {
	private String id;
	private String name;
	private String type;
	private ShipComInfo shipComInfo;
	private double capacity;
	private int psnNum;
	private int boxNum;
	private double length;
	private double width;
	private double depth;
	private String dockyard;
	private java.sql.Date launchDate;
	private int limitYears;
	private String comments;

	public ShipInfo() {
		
	}
	public ShipInfo(String id) {
		DBConnectionManager connMgr = DBConnectionManager.getInstance();
	
		Connection con = connMgr.getConnection("shipping_export");
		if (con == null) {
			System.out.println("不能获得数据库连接");
			return;
		}
		Statement stmt = null;
		ResultSet rs = null;
		
		try {
			stmt = con.createStatement();
			rs = stmt.executeQuery("select * from ShipInfo where Ship_ID = '" + id + "'");
		
			rs.next();
			this.id = id;
			name = rs.getString("Ship_Name");
			type = rs.getString("Ship_Type");
			shipComInfo = new ShipComInfo(rs.getString("ShipCom_ID"));
			capacity = rs.getDouble("Ship_Capacity");
			psnNum = rs.getInt("Ship_PsnNum");
			boxNum = rs.getInt("Ship_BoxNum");
			length = rs.getDouble("Ship_Length");
			width = rs.getDouble("Ship_Width");
			depth = rs.getDouble("Ship_Depth");
			dockyard = rs.getString("Ship_Dockyard");
			launchDate = rs.getDate("Ship_LaunchDate");
			limitYears = rs.getInt("Ship_LimitYears");
			comments = rs.getString("Ship_Comments");
			
			stmt.close();
			rs.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		connMgr.freeConnection("shipping_export", con);
		connMgr.release();
	}
	
	public void setId(String id) {
		this.id = id;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setType(String type) {
		this.type = type;
	}
	public void setShipComInfo(ShipComInfo shipComInfo) {
		this.shipComInfo = shipComInfo;
	}
	public void setCapacity(double capacity) {
		this.capacity = capacity;
	}
	public void setPsnNum(int psnNum) {
		this.psnNum = psnNum;
	}
	public void setBoxNum(int boxNum) {
		this.boxNum = boxNum;
	}
	public void setLength(double length) {
		this.length = length;
	}
	public void setWidth(double width) {
		this.width = width;
	}
	public void setDepth(double depth) {
		this.depth = depth;
	}
	public void setDockyard(String dockyard) {
		this.dockyard = dockyard;
	}
	public void setLaunchDate(java.sql.Date launchDate) {
		this.launchDate = launchDate;
	}
	public void setLimitYears(int limitYears) {
		this.limitYears = limitYears;
	}
	public void setComments(String comments) {
		this.comments = comments;
	}

	public String getId() {
		return id;
	}
	public String getName() {
		return name;
	}
	public String getType() {
		return type;
	}
	public ShipComInfo getShipComInfo() {
		return shipComInfo;
	}
	public double getCapacity() {
		return capacity;
	}
	public int getPsnNum() {
		return psnNum;
	}
	public int getBoxNum() {
		return boxNum;
	}
	public double getLength() {
		return length;
	}
	public double getWidth() {
		return width;
	}
	public double getDepth() {
		return depth;
	}
	public String getDockyard() {
		return dockyard;
	}
	public java.sql.Date getLaunchDate() {
		return launchDate;
	}
	public int getLimitYears() {
		return limitYears;
	}
	public String getComments() {
		return comments;
	}
}
